/*
 * @Date: 2022-01-21 17:39:32
 * @LastEditors: wwz
 * @LastEditTime: 2022-12-28 15:11:25
 * @Description:
 */
import router from './router'
// import store from './store'
// import { getToken } from '@/utils/auth'

const whiteList = [
  '/login'
]

router.beforeEach((to, from, next) => {
  if (localStorage.getItem('linting-client-pc-store')) {
    // 有token
    if (to.path === '/login') {
      // 有token 直接进入登陆后首页
      next()
      // console.log(123)
      // next({ path: '/' })
    } else {
      next()
    }
  } else {
    // 没有token
    if (whiteList.indexOf(to.path) !== -1) {
      // console.log("白名单", to);
      next()
    } else {
      // 不在白名单
      next({ name: 'lt-login', params: to.params }) // 否则全部重定向到登录页
    }
  }
})
